package com.example.connect_mysql_demo.web;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class WebsitesController {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @RequestMapping(value = "/get_websites", method = RequestMethod.GET)
    @ResponseBody
    public List<Map<String, Object>> getUsers() {
        String sql = "select * from websites";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}
